import requests


for page in range(1, 5):
    url = f'https://v.6.cn/minivideo/getMiniVideoList.php?act=recommend&page={page}&pagesize=20'
    headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'
    }
    resp = requests.get(url, headers=headers)
    html_data = resp.json()
    vid_list = html_data['content']['list']
    # print(vid)

    for imen in vid_list:
        name = imen['alias']
        title = imen['title']
        playurl = imen['playurl']
        try:
            # vids_list.append(playurl)
            resp_1 = requests.get(playurl, headers=headers).content
            with open(f'vid/{title}.mp4', mode='wb') as f:
                f.write(resp_1)
                print(f'{title}保存成功！')
        except:
            pass
